<template>
  <div>
    <el-button @click="dialogVisible = true">新增教师</el-button>
    <el-dialog
      title="新增教师信息"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
      :close-on-click-modal="false"
      center
    >
      <el-main>
        <el-form label-width="70px">
          <el-form-item label="工号">
            <el-input v-model="teacherInfo.teacherId" placeholder="请输入工号" size="small" />
          </el-form-item>
          <el-form-item label="姓名">
            <el-input v-model="teacherInfo.name" placeholder="请输入姓名" size="small" />
          </el-form-item>
          <el-form-item label="性别">
            <el-select v-model="teacherInfo.gender" placeholder="请选择" size="small">
              <el-option
                v-for="item in options.gender"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="职称">
            <el-select v-model="teacherInfo.academicTitle" placeholder="请选择" size="small">
              <el-option
                v-for="item in options.academicTitle"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="联系方式">
            <el-input v-model="teacherInfo.phoneNumber" placeholder="请输入联系方式" size="small"></el-input>
          </el-form-item>
        </el-form>
      </el-main>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false">新增信息</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      teacherInfo: {
        teacherId: "",
        name: "",
        phoneNumber: "",
        gender: "",
        academicTitle: ""
      },
      options: {
        gender: [
          {
            value: "1",
            label: "男"
          },
          {
            value: "2",
            label: "女"
          }
        ],
        academicTitle: [
          {
            value: "1",
            label: "教授"
          },
          {
            value: "2",
            label: "副教授"
          },
          {
            value: "3",
            label: "讲师"
          }
        ]
      }
    };
  },
  methods: {
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(_ => {
          done();
        })
        .catch(_ => {});
    }
  }
};
</script>

<style lang="less" scoped>
/deep/ .el-dialog {
  border-radius: 5px;
}

/deep/ .el-dialog__header {
  background-color: rgb(51, 55, 68);
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

/deep/ .el-dialog__title {
  font-size: 23px;
  color: white;
}
/deep/ .el-dialog__body{
  padding: 25px 25px 0px;
}
/deep/ .el-input {
  width: 220px;
  margin-left: 40px;
  padding: 0;
}


.el-main {
  align-items: center;
}

.el-main div:nth-child(n + 2) {
  margin-top: 10px;
}

.el-main div label {
  color: rgb(51, 55, 68);
  display: inline-block;
  width: 70px;
  font-size: 15px;
}

.el-button--primary {
  background-color: rgb(51, 55, 68);
  color: white;
  border: 0;
  width: 150px;
}
</style>